import java.util.Locale;
import java.util.Scanner;

class Student implements Cloneable {
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

class Example {
    String str = new String("good");
    char[] ch = {'a','b','c'};

    public static void main(String[] args) {
        Example ex = new Example();
        ex.change(ex.str,ex.ch);
        System.out.print(ex.str + " and ");
        System.out.print(ex.ch);
    }

    public void change(String str,char ch[]) {
        str = "tesk ok";
        ch[0] = 'g';
    }
}



public class Test {


    public static void func() {
        func();
    }

    public static void main20(String[] args) {
        String s1 = "abc" + "def";
        String s2 = new String(s1);
        if(s1.equals(s2))
            System.out.println(".equals succeeded");
        if(s1 == s2)
            System.out.println("== succeeded");
    }

    private boolean isPalidrome(String s) {
        s = s.toLowerCase();
        int i = 0;
        int j = s.length()-1;
        while(i < j) {
            while(i < j && !Character.isLetterOrDigit(s.charAt(i))) {
                i++;
            }
            while(i < j && !Character.isLetterOrDigit(s.charAt(j))) {
                j--;
            }
            if(s.charAt(i) != s.charAt(j)) {
                return false;
            }
            i++;
            j--;
        }
        return true;
    }

    private boolean isNumberOrCharacter(char ch) {
        //isDigit 是不是数字字符
        if(Character.isDigit(ch) || Character.isLetter(ch)) {
            return true;
        }
        return false;
    }

    public static void main18(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNextInt()) {

            String str = in.nextLine();

            int index = str.lastIndexOf(" ");

            String ret = str.substring(index+1);

            System.out.println(ret.length());

        }
     }

    public static void main17(String[] args) {
        Scanner in = new Scanner(System.in);
        //注意 hasNext 和 hasNextLine 的区别
        while(in.hasNextLine()) {

            String str = in.nextLine();
            String[] ret = str.split(" ");
            System.out.print(ret[ret.length-1].length());
            //this is a good day
            // 1. split
            // 2. 找到最后一个空格的位置 - > lastIndexof,利用 subString(13)
        }
    }

    public static void main16(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("abc").append("def");
        stringBuffer.append("hello");
        System.out.println(stringBuffer);

        stringBuffer.reverse();

        System.out.println(stringBuffer);

        String str = stringBuffer.toString();

        String s = "fdsfa";
        StringBuffer stringBuffer2 = new StringBuffer();
        stringBuffer2.append(s);
        System.out.println(stringBuffer2);
    }

    public static void main15(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("abc").append("def");
        stringBuilder.append("hello");
        System.out.println(stringBuilder);

        stringBuilder.reverse();

        System.out.println(stringBuilder);
    }

    public static void main14(String[] args) {
        long start = System.currentTimeMillis();
        String s = "";
        for (int i = 0; i < 10000; i++) {
            s += i;
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }

    public static void main13(String[] args) {
        String s = "hello";
        s = s+"world";
        System.out.println(s);
    }

    public static void main12(String[] args) {
        final int[] array = {1,2,3,4};
        //array = new int[]{1,2,3,4};
        array[0] = 99;
    }

    public int firstUniqChar(String s) {

        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            count[ch - 97]++;
        }

        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if(count[ch-97] == 1) {
                return i;
            }
        }

        return -1;
    }


    public static void main11(String[] args) {
        char[] ch = new char[]{'a','b','c'};
        String s1 = new String(ch);

        s1.intern();

        String s2 = "abc";
        System.out.println(s1 == s2);

        System.out.println("s1地址：0x"+Integer.toHexString(System.identityHashCode(s1)));
        System.out.println("s1地址：0x"+Integer.toHexString(System.identityHashCode(s1)));
    }

    public static void main10(String[] args) {
        char[] ch = new char[]{'a','b','c'};
        String s1 = new String(ch);

        String s2 = "abc";
        System.out.println(s1 == s2);
    }

    public static void main9(String[] args) {
        String str = "abcdef";
        //[1,4)
        String sub = str.substring(1,4);
        System.out.println(sub);
    }

    public static void main8(String[] args) {
        String str = "name=zhangsan&age=10";
        String[] result = str.split("&");
        for(String s : result) {
            String[] ss = s.split("=");
            for(String sss : ss) {
                System.out.println(sss);
            }
        }
    }

    public static void main7(String[] args) {
        String str = "name=zhangsan&age=10";
        String[] result = str.split("=|&");
        for(String s : result) {
            System.out.println(s);
        }
    }

    public static void main6(String[] args) {
        String str = "192.167.1.1";
        String[] result = str.split("\\.");
        for(String s : result) {
            System.out.println(s);
        }
    }

    public static void main5(String[] args) {
        String str = "hello world hello bit";
        String[] result = str.split(" ",2);
        for(String s : result) {
            System.out.println(s);
        }
    }

    public static void main4(String[] args) {
        String str = "ababcabcdef";
        String ret1 = str.replace('a','p');
        String ret2 = str.replace("ab","kkpp");
        String ret3 = str.replaceAll("ab","kkpp");
        System.out.println(ret1);
        System.out.println(ret2);
        System.out.println(ret3);
    }

    public static void main3(String[] args) {
        String str = "abcef";
        char[] crr = str.toCharArray();
        for(char ch : crr) {
            System.out.println(ch+"");
        }
        System.out.println();

        char[] array = {'a','b','c'};
        String s = new String(array);
        System.out.println(s);

        String s2 = String.format("%d-%d-%d",2100,9,14);
        System.out.println(s2);
    }

    public static void main2(String[] args) {
        int a = 123;
        String str = String.valueOf(a);
        System.out.println(str);

        System.out.println(String.valueOf(12.4));

        String s4 = String.valueOf(new Student("Hanmeimei",18));
        System.out.println(s4);
        System.out.println("=================");

        //将字符串 "123" 转换为整数类型 int
        int i = Integer.parseInt("123");
        System.out.println(i+1);

        double d = Double.parseDouble("12.45");
        System.out.println(d);
        System.out.println("==================");

        String str2 = "hello";
        String ret = str2.toUpperCase();
        System.out.println(ret);

        String str3 = "HEllo";
        String ret2 = str3.toLowerCase();
        System.out.println(ret2);

    }

    public static void main1(String[] args) {
        String str = "ababcabcdabcdef";

        System.out.println(str.lastIndexOf("abc"));

        System.out.println(str.indexOf("abc"));

        int i = str.indexOf('c',3);
        System.out.println(i);

        for (int j = 0; j < str.length(); j++) {
            char ch = str.charAt(j);
            System.out.print(ch+"");
        }
    }
}
